package com.mrchip.service_intent;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {

    private int mProcess;
    private ServiceBinder mBinder;
    public MyService() {
    }

    class ServiceBinder extends Binder {
        public void startTask() {
            Log.d("MyService", "Start Task");
        }

        public int getTaskProcess() {
            Log.d("MyService", "Progress:" + mProcess++);
            return mProcess;
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        Log.e("Service", "onBind");
        return mBinder;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d("Service", "onStartCommand");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("Service", "onCreate");
        mProcess = 0;
        mBinder = new ServiceBinder();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e("Service", "onDestroy");
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.e("Service", "onUnbind");
        return super.onUnbind(intent);
    }

    @Override
    public void onRebind(Intent intent) {
        Log.e("Service", "onRebind");
        super.onRebind(intent);
    }
}
